package mysql

import (
	"gorm.io/gorm"
	"time"
	"week2d/models/global"
	"week2d/models/request"
)

// 课程首页
type GoodsWeek2d struct {
	gorm.Model
	GoodsTitle  string    `gorm:"type:varchar(30);comment:课程标题;"`
	GoodsAvatar string    `gorm:"type:varchar(255);comment:课程图片;"`
	GoodsStatus int       `gorm:"type:tinyint(1);comment:课程状态 0 代表名额不足 1代表可预约;"`
	YyTime      time.Time `gorm:"type:datetime(0);comment:预约时间;"`
}

// 新增课程
func GoodsCreate(goods request.GoodsCreateWeek2d) error {
	data := GoodsWeek2d{
		GoodsTitle:  goods.GoodsTitle,
		GoodsAvatar: goods.GoodsAvatar,
		GoodsStatus: goods.GoodsStatus,
		YyTime:      time.Unix(time.Now().Unix(), time.Now().Unix()),
	}

	return global.DB.Create(&data).Error

}
